#!/usr/bin/env python

# 2010-05-19
# It can be seen that the number, 125874, and its double, 251748, contain exactly the same digits, but in a different order.
# Find the smallest positive integer, x, such that 2x, 3x, 4x, 5x, and 6x, contain the same digits.

def is_same_digit(n):
    l1 = list(str(n))
    l2 = list(str(n * 2))
    l3 = list(str(n * 3))
    l4 = list(str(n * 4))
    l5 = list(str(n * 5))
    l6 = list(str(n * 6))
    
    l1.sort()
    l2.sort()
    l3.sort()
    l4.sort()
    l5.sort()
    l6.sort()

    s1 = "".join(l1)
    s2 = "".join(l2)
    s3 = "".join(l3)
    s4 = "".join(l4)
    s5 = "".join(l5)
    s6 = "".join(l6)
    
    if s1 == s2 and s1 == s3 and s1 == s4 and s1 == s5 and s1 == s6:
        return True
    else:
        return False

if __name__ == "__main__":
    num = 1
    while not is_same_digit(num):
        num = num + 1
    print num
